package com.example.client_anna.util.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import org.jetbrains.annotations.NotNull;

import java.util.List;

/**
 * @author cy
 * @email 272884043@qq.com
 * @date 2021/10/19
 */
public class Page2FragmentAdapter extends FragmentStateAdapter {

    private List<Fragment> list;

    public static Page2FragmentAdapter start(@NonNull @NotNull FragmentActivity fragmentActivity,List<Fragment> fragments) {
        return new Page2FragmentAdapter(fragmentActivity,fragments);
    }


    public Page2FragmentAdapter(@NonNull @NotNull FragmentActivity fragmentActivity,List<Fragment> fragments) {
        super(fragmentActivity);
        this.list = fragments;
    }

    @NonNull
    @NotNull
    @Override
    public Fragment createFragment(int i) {
        return list.get(i);
    }

    @Override
    public int getItemCount() {
        return list.size();
    }
}
